package org.devocean.groupbuying.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderColumn;

@SuppressWarnings("serial")
@Entity
public class Deal implements Serializable {

	@Id
	@GeneratedValue
	private Integer dealID;
	private Date expireDate;
	private Date startDate;
	private Integer tippingPoint;
	private Integer maxPurchase;
	private Integer purchaseNumber;
	private String type;
	private String status;

	@OneToMany(cascade = CascadeType.ALL, mappedBy = "deal")
	@OrderColumn(name = "discountPrice")
	private Set<Discount> discounts = new HashSet<Discount>();

	@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinColumn(name = "articlesLocalizationID", referencedColumnName = "articlesLocalizationID", nullable = false)
	private ArticlesLocalization articlesLocalization;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "productID", referencedColumnName = "productID", nullable = false)
	private Product product;
	
	public Integer getDealID() {
		return dealID;
	}

	public void setDealID(Integer dealID) {
		this.dealID = dealID;
	}

	public Date getExpireDate() {
		return expireDate;
	}

	public void setExpireDate(Date expireDate) {
		this.expireDate = expireDate;
	}

	public Integer getTippingPoint() {
		return tippingPoint;
	}

	public void setTippingPoint(Integer tippingPoint) {
		this.tippingPoint = tippingPoint;
	}

	public Integer getMaxPurchase() {
		return maxPurchase;
	}

	public void setMaxPurchase(Integer maxPurchase) {
		this.maxPurchase = maxPurchase;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public Set<Discount> getDiscounts() {
		return discounts;
	}

	public void setDiscounts(Set<Discount> discounts) {
		this.discounts = discounts;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}


	public Integer getPurchaseNumber() {
		return purchaseNumber;
	}

	public void setPurchaseNumber(Integer purchaseNumber) {
		this.purchaseNumber = purchaseNumber;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public ArticlesLocalization getArticlesLocalization() {
		return articlesLocalization;
	}

	public void setArticlesLocalization(ArticlesLocalization articlesLocalization) {
		this.articlesLocalization = articlesLocalization;
	}

	@Override
	public String toString() {
		return "Deal [dealID=" + dealID + ", expireDate=" + expireDate
				+ ", tippingPoint=" + tippingPoint + ", maxPurchase="
				+ maxPurchase + ", purchaseNumber=" + purchaseNumber
				+ ", type=" + type + ", status=" + status + "]";
	}

}
